<?php

include_once APPLICATION_DIR . "/application/model/NEWSLETTER.php";

class Newsletter extends DataObjects_NEWSLETTER
{	
	public function validateInput(){
		global $error_msg;

		if(!textvalid($this->EMAIL)){
			$error_msg->add(stripslashes(_LB_EMAIL_IS_EMPTY));
		}

		if(strlen($this->EMAIL)> MAX_LENGTH_NAME){
			$error_msg->add(stripslashes(_MSG_EMAIL_IS_TOO_LONG));
		}

		return $error_msg->isNoError();
	}
	
	public static function isExist($email) {
		$newsletter = new Newsletter();
		$newsletter->EMAIL = $email;
		$newsletter->find();

		return (($newsletter->N > 0) ? 1 : 0);
	}

	public static function getList() {
		$newsletter = new Newsletter();
		return $newsletter->fetchList();
	}
}
?>
